﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Medianamik.Core.DAL.SQL
{
    public class ParameterCollectionExpression : IExpression 
    {
        private List<IParameter> _parameters; 
        public IEnumerable<IParameter> Parameters
        { 
            get
            {
                return _parameters;
            }
        }
        public ParameterCollectionExpression(IEnumerable<IParameter> pParams)
        {
            _parameters = new List<IParameter>();
            _parameters.AddRange(pParams);
        }
        #region ISqlQueryPart Members

        public StringBuilder ToSQL()
        {
            var sql= new StringBuilder(" ( ");
            sql.Append(Parameters.First().Name);
            foreach (var parameter in Enumerable.Skip(Parameters,1))
            {
                sql.Append(", " + parameter.Name);
            }
            sql.Append(" ) ");

            return sql;
        }

        #endregion
    }
}
